package gui_2.panel;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class TestMainFrame extends JFrame {

    // 上面的面板
    UpPanel u1;
    FloorPanel f1;

    public TestMainFrame(){
        this.setSize(600, 400);
        this.setLocationRelativeTo(null);
        this.setDefaultCloseOperation(3);

        // 创建上面的面板
        u1 = new UpPanel();
        f1 = new FloorPanel();

        f1.b5.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if(f1.text1.getText().equals("1")|| f1.text1.getText().equals("2")||
                        f1.text1.getText().equals("3")||f1.text1.getText().equals("4")||
                        f1.text1.getText().equals("6")||f1.text1.getText().equals("5")){
                    u1.getCardLayout().show(u1, f1.text1.getText());
                }else{
                    JOptionPane.showMessageDialog(null, "找不到该图片");
                }
            }
        });

        f1.b4.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                u1.getCardLayout().last(u1);
            }
        });

        f1.b3.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                u1.getCardLayout().next(u1);
            }
        });

        f1.b2.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                u1.getCardLayout().previous(u1);
            }
        });

        f1.b1.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                u1.getCardLayout().first(u1);
            }
        });

        this.add(u1, BorderLayout.CENTER);
        this.add(f1, BorderLayout.SOUTH);
        this.setVisible(true);
    }


    public static void main(String[] args){
        new TestMainFrame();
    }
}
